From: Marco Trevisan (TreviƱo) Date: Fri, 8 Mar 2019 20:36:23 +0000 (-0600) Subject: boxpointer: Compute source allocation and work area just once X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~861^2^2~11 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=244a329ee76b90c912b90f367ced166abc8d0356;p=gnome-shell.git boxpointer: Compute source allocation and work area just once Compute the source actor workarea and allocation when repositioning and keep it cached so that we've not to calculating it again in _calculateArrowSide. Since _calculateArrowSide only is called inside _updateFlip that is always called just after reposition, we can be sure that the computed values are still correct. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435 --- diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js index 82dbbaf6a..c8e5ceda7 100644 --- a/js/ui/boxpointer.js +++ b/js/ui/boxpointer.js @@ -473,11 +473,15 @@ var BoxPointer = GObject.registerClass({ _reposition() { let sourceActor = this._sourceActor; let alignment = this._arrowAlignment; + let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor); + + this._sourceAllocation = Shell.util_get_transformed_allocation(sourceActor); + this._workArea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex); // Position correctly relative to the sourceActor let sourceNode = sourceActor.get_theme_node(); let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box()); - let sourceAllocation = Shell.util_get_transformed_allocation(sourceActor); + let sourceAllocation = this._sourceAllocation; let sourceCenterX = sourceAllocation.x1 + sourceContentBox.x1 + (sourceContentBox.x2 - sourceContentBox.x1) * this._sourceAlignment; let sourceCenterY = sourceAllocation.y1 + sourceContentBox.y1 + (sourceContentBox.y2 - sourceContentBox.y1) * this._sourceAlignment; let [minWidth, minHeight, natWidth, natHeight] = this.get_preferred_size(); @@ -485,8 +489,7 @@ var BoxPointer = GObject.registerClass({ // We also want to keep it onscreen, and separated from the // edge by the same distance as the main part of the box is // separated from its sourceActor - let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor); - let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex); + let workarea = this._workArea; let themeNode = this.get_theme_node(); let borderWidth = themeNode.get_length('-arrow-border-width'); let arrowBase = themeNode.get_length('-arrow-base'); @@ -606,10 +609,9 @@ var BoxPointer = GObject.registerClass({ } _calculateArrowSide(arrowSide) { - let sourceAllocation = Shell.util_get_transformed_allocation(this._sourceActor); + let sourceAllocation = this._sourceAllocation; let [minWidth, minHeight, boxWidth, boxHeight] = this.get_preferred_size(); - let monitorIndex = Main.layoutManager.findIndexForActor(this._sourceActor); - let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex); + let workarea = this._workArea; switch (arrowSide) { case St.Side.TOP: